Repository navigation
MCP profiles part 5: Codex threads apply their profile's outside servers - #826
Merged
Merged
Conversation
Each Codex thread T3 loads on the shared app-server gets mcp_servers.<name>.enabled = false in its own per-request config for every server config/read lists for its folder that the profile leaves out (launch-argument and project servers included; T3's own entries stay). Each turn first reads the thread's live servers and refuses, saying why and the fix, when one outside the profile is still on. A missing or broken profile, a server list T3 cannot read, or a thread T3 cannot match is refused, never started with every server. Logic in apps/server/src/fork/codexMcpProfile.ts; two seam lines in the Codex adapter (announced in step 1). Remote delegation stays Claude-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and connectors - Watch turn/started: a turn Codex starts on its own (a goal's next turn, a sub-agent's turn) gets the same check as turn/start; one that fails is stopped (goal paused, turn interrupted) and ends failed with the reason. - Count Codex sub-agents as their parent's T3 thread (they copy the parent's loaded config, codex-rs child_config.rs), so their turns are checked too. - Send features.apps=false when a narrowed profile leaves out codex_apps, which config/read never lists. - A refused resume no longer becomes a fresh Codex session: the fallback start is refused once, so the history is kept. - Tests for each, with Codex's real status words; docs updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 21, 2026
Conflict: .github/fork-seams.json. Resolved as main's file plus this PR's one intended seam change: the two CodexAdapterV2.ts lines move from "announced" to "added". The branch's copy had also dropped other PRs' announcements (environment facts P3, thread menu, HO5) and the packages/shared/src/slotObserve* entry; those are kept from main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
lens: code · reviewer: claude-opus-5-5 · read at: c0682b7 Head re-read after merge from main. I read only the merge commit ( blocker: none
State question:
Verdict: SAFE (merge path unchanged; this lens covers only the merge from main). |
Resolve FORK_CHANGES.md: main's table plus this PR's MCP profiles row change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MCP profile design PR 5 (code; step 2 after the announce PR #801).
What and why
Today only Claude threads apply MCP profiles; a Codex thread whose profile is narrower than
allis refused as its turn starts (#672). This makes Codex apply the profile's outside servers (design section 6), per thread on the shared app-server (design section 9).apps/server/src/fork/codexMcpProfile.ts(new) wraps the Codex adapter's app-server client factory. For eachthread/start,thread/resumeandthread/forkthat T3 sends, it does three things:T3CODE_THREAD_ID, which is already in the config, or for a resume from the Codex thread it loaded before;config/readwith the thread's folder, which MCP servers are set up. This coversconfig.toml, a project's.codex/config.toml, and servers added by-c mcp_servers…in the launch arguments (upstream [Bug]: Codex per-threadmcp_serversoverride replaces MCP servers added with-claunch args pingdotgg/t3code#15828). It then addsmcp_servers.<name>.enabled = falseto that request's config for each server the profile leaves out. T3's ownt3-codeandt3-code-directentries are never touched.The overrides go only into that one request's config, so another thread on the same app-server keeps its own set.
Before each
turn/start, and before athread/goal/setthat is not "paused", T3 reads the thread's live servers (mcpServerStatus/list, every page). If a server outside the profile is still on, it refuses the turn, says why and gives the fix: pickallfor the thread, or fix the profile. It refuses when:These also refuse, and never start a thread with every server:
t3Toolsnot"all";Refusals use code -32001, not -32600, which the adapter reads as "thread not found". A thread on
allis loaded exactly as before, with no extra request.mcpProfile.ts:MCP_PROFILE_DRIVERSnow includescodex, so the turn check (Narrowed MCP profile: refuse at turn start on providers that cannot apply it (#669 follow-ups) #672) no longer refuses Codex. Remote delegation keeps a separateMCP_PROFILE_REMOTE_DRIVERS(Claude only), because a machine that carries profiles may run a T3 from before this change.claudeMcpProfile.ts: newmakeThreadMcpProfilesById, which reads the profile by thread id from the store. It uses the same lineage reads as Claude.The seam: two lines in
CodexAdapterV2.ts, the import and the spread of the wrappedclientFactory. fork seams: announce the Codex MCP profile lines (MCP profiles part 5, step 1) #801 announced them; this PR moves them toadded.Docs:
docs/fork/README.md(server.mcpProfiles) andFORK_CHANGES.md.The server names come from
config/readand not the existinglistEnabledMcpServers: that one reads only the homeconfig.tomland launch args, and misses project.codex/config.tomlservers.Tests
apps/server/src/fork/codexMcpProfile.test.ts(new, 27 tests) uses a fake app-server. Its config is per thread, and a resume of a loaded thread keeps the old config, as real Codex does. The tests cover:t3Tools, a bad name, or an unreadable or malformed server list refuses with the fix;createCodexAdapterV2through the seam lines.mcpProfileTurnCheck.test.tsis updated: Codex runs, and OpenCode is the refused example. These all pass:CodexAdapterV2.test.ts, 417 tests;apps/servertypecheck;fork-seam-check.cjs, green against fork seams: announce the Codex MCP profile lines (MCP profiles part 5, step 1) #801's list;fork-seam-check.test.cjs, 114 passing.Red checks: each line below was removed in turn, and a test failed each time.
narrowedflagcodexinMCP_PROFILE_DRIVERSOn the old code, the new tests fail. With main's driver list, Codex turns are refused.
No Codex binary was installed for this. A live check would add a real codex-cli app-server run of the same cases: per-thread enabled=false, a launch-arg server switched off, a resume ignoring config while the thread is loaded, project servers from
config/read, and whether Codex's own sub-agents inherit the thread's config.Follow-ups:
General vs project
General: MCP profiles on Codex threads, for any T3 fork user. No project facts.
Upstream fit
Read only. This uses the same
mcp_servers.<name>.enabled=falsekeys that upstream'sCodexTextGeneration.tsuses. It is per-thread config, like upstream's ownt3-codeentry and its launch-arg handling (upstream issue pingdotgg#15828 and PR pingdotgg#15839). All logic is in a fork file, plus two seam lines. I found no upstream issue or PR about per-thread MCP profiles on Codex.MCP profile design PR 5
After the fix round (#801 lenses): Codex threads get
mcp_servers.<name>.enabled=falsefor each configured server the profile leaves out, andfeatures.apps=falseunless it namescodex_apps. Codex's own sub-agents copy this config (checked in codex-rschild_config.rs). Every turn is checked against the live server list, including turns Codex starts itself for a goal or a sub-agent. A failing turn is stopped, its goal is paused, and it ends failed with the reason. A refused resume fails the turn instead of starting a fresh session. Follow-ups: #814.🤖 Generated with Claude Code